package com.lpf.www.common.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @Author lpf
 * @Date 2022/1/4 下午10:12
 * @ProjectName live-streaming-os
 * @Version 1.0
 * @Description:
 */
public class JedisUtils {
    private static final String REDIS_IP = "192.168.1.11";
    private static final Integer REDIS_PORT = 6379;
    private static final String REDIS_PASSWORD = "123456";
    private static final Integer REDIS_TIMEOUT = 5000;

    public static JedisPool getJedisPool(){
        return new JedisPool(new JedisPoolConfig(), REDIS_IP, REDIS_PORT, REDIS_TIMEOUT, REDIS_PASSWORD);
    }

    public static Jedis getJedis(){
        return getJedisPool().getResource();
    }

    public static void closeJedis(Jedis jedis){
        if (jedis != null){
            jedis.close();
        }
    }

}
